package com.wyl.selenium.controller;

import com.wyl.selenium.common.CommonPage;
import com.wyl.selenium.common.ResponseData;
import com.wyl.selenium.dto.ProjectBaseInfoDto;
import com.wyl.selenium.req.ProjectBaseInfoReq;
import com.wyl.selenium.service.ProjectBaseInfoService;
import com.wyl.selenium.vo.LabelNodeVo;
import com.wyl.selenium.vo.ProjectBaseInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * @Description
 * @Author WuYiLong
 * @Date 2023/11/28 10:41
 */
@Api(tags = "项目基本信息api")
@RestController
@RequestMapping(value = "projectBaseInfo")
@Validated
public class ProjectBaseInfoController {

    @Autowired
    private ProjectBaseInfoService projectBaseInfoService;

    @ApiOperation(value = "筛选列表")
    @GetMapping(value = "listLabelNode")
    public ResponseData<List<LabelNodeVo>> listLabelNode() {
        return ResponseData.successInstance(projectBaseInfoService.listLabelNode());
    }

    @ApiOperation(value = "分页")
    @PostMapping(value = "pageProjectBaseInfo")
    public ResponseData<CommonPage<List<ProjectBaseInfoVo>>> pageProjectBaseInfo(@RequestBody ProjectBaseInfoReq projectBaseInfoReq) {
        return ResponseData.successInstance(projectBaseInfoService.pageProjectBaseInfo(projectBaseInfoReq));
    }

    @ApiOperation(value = "保存")
    @PostMapping(value = "saveProjectBaseInfo")
    public ResponseData saveProjectBaseInfo(@RequestBody ProjectBaseInfoDto projectBaseInfoDto) {
        projectBaseInfoService.saveProjectBaseInfo(projectBaseInfoDto);
        return ResponseData.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping(value = "deleteProjectBaseInfo")
    public ResponseData deleteProjectBaseInfo(@NotNull(message = "参数ids不能为空") Long[] ids) {
        projectBaseInfoService.deleteProjectBaseInfo(Arrays.asList(ids));
        return ResponseData.success();
    }
}
